package com.cndatacom.ccsinfoMgr.dao.impl;

import com.cndatacom.ccsinfoMgr.dao.IDownloadInfoDao;
import com.cndatacom.ccsinfoMgr.model.DownloadInfo;
import com.cndatacom.eweb.common.PaginationModel;
import com.cndatacom.eweb.common.PaginationSupport;

public class DownloadInfoDao extends PaginationSupport implements IDownloadInfoDao {

	public boolean deleteDownloadInfo(DownloadInfo downloadInfo) {
		getHibernateTemplate().delete(downloadInfo);
		return true;

	}

	public PaginationModel getAllDownloadInfo(int offset, int pageSize) {
		return searchPaginated("select di from DownloadInfo di order by di.id desc", offset, pageSize);
	}

	public PaginationModel getDownloadInfoByHQL(String hql, int offset, int pageSize) {
		return searchPaginated(hql, offset, pageSize);
	}

	public DownloadInfo getDownloadInfoById(int id) {
		return (DownloadInfo)getHibernateTemplate().get(DownloadInfo.class, id);
	}

	public DownloadInfo saveOrUpdateDownloadInfo(DownloadInfo downloadInfo) {
		getHibernateTemplate().saveOrUpdate(downloadInfo);
		return downloadInfo;
	}

}

